package cn.zqy.demo.day07;

import java.util.ArrayList;

public class Demo08ArrayListPersion {
    public static void main(String[] args) {
        ArrayList<Persion> list = new ArrayList<>();

        Persion p1 = new Persion(12,"王昭君");
        Persion p2 = new Persion(33,"大桥");
        Persion p3 = new Persion(45,"武则天");

        // 添加
        list.add(p1);
        list.add(p2);
        list.add(p3);
        list.add(p1);

        // 遍历
        for (int i = 0; i < list.size(); i++) {
            System.out.println("第" + i + "号位置的名字：" + list.get(i).getName() + "年龄：" + list.get(i).getAge());
        }

    }
}
